<template>
	<view>
		<view class="flex flex-col pt80" v-if="!list.length">
			<image src="/static/img/my/address.png" class="h320 w320 " mode=""></image>
			<view class="color-B7B5B5 mt48">
				您还未添加收件地址~
			</view>
		</view>
		<view class="">
			<view v-for="(item,index) in list" :key="index" @click.stop="set(item)"
				class="bg-fff  m20 p20 pt28 radius20">
				<view class="flex row-between">
					<view class="">{{item.name}}</view>
					<view class="">{{item.mobile}}</view>
				</view>
				<view class="color-666 fs26 pt20 pb20 border-b">{{item.address}}</view>
				<view class="fs28 color-666 flex fs24 mt30">
					<view class="flex" @click.stop="$u.route('/pages/my/address/addAddress',item)">
						<image src="/static/img/my/edit.png" class="h32 w32" mode=""></image>
						<view class="color-fs ml14">修改</view>
					</view>
					<view class="flex ml60" @click.stop="del(item)">
						<image src="/static/img/my/delete.png" class="h32 w32 " mode=""></image>
						<view class="color-zs ml14">删除</view>
					</view>
				</view>
			</view>
		</view>
		<view class="bg-zs color-fff  h84 radius12 flex row-center mt60 mx40"
			@click.stop="$u.route('/pages/my/address/addAddress')">
			+ 添加收件信息
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: ''
			};
		},
		onShow() {
			this.getList()
		},
		methods: {
			getList() {
				this.$request('/member/my/addressList').then(res => {
					this.list = res.data.data
				})
			},
			set(item) {
				if (!this.$params.sel) return
				uni.$emit('set_address', item)
				this.$navBack()
			},
			del(item) {
				this.$showModal('删除').then(res => {
					this.$request('/member/my/addressDel', {
						id: item.id
					}).then(res => {
						this.$msg(res.msg)
						this.getList()
					})
				})
			}
		}
	}
</script>

<style lang="scss">
	// page {
	// 	background-color: #FFFFFF;
	// }
</style>
